<!--<link href="/assets/plugins/bootstrap-datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
<link href="/assets/css/datetimepicker.css" rel="stylesheet" type="text/css"/ -->



<div style="margin:0 auto; width:80%" class="dashboard">

	<?php $form=$this->beginWidget('CActiveForm', array(
		//'id'=>'SearchByDate',
		'enableClientValidation'=>true,
		'htmlOptions'=>array('enctype'=>'multipart/form-data'),
		'method' => 'GET',
		'action' => '/3.0/prestige/tickets/dashBoard/view/'
	)); ?>
	
	<div style="margin-top: 50px">
		<label for="dateBegin" style="width:200px; display:block; font-weight:bold;">Start Date: </label>
		<?php $this->widget('zii.widgets.jui.CJuiDatePicker',array(
				'name'=>'dateBegin',
				// additional jvascript options for the date picker plugin
				'options'=>array(
					'showAnim'=>'fold',
				),
				'htmlOptions'=>array(
					'style'=>'height:20px; width: 196px;',
				),
		)); ?>
	</div>
	
	<div style="margin-top: 20px">
		<label for="dateEnd" style="width:200px; display:block; font-weight:bold;">End Date: </label>
		<?php $this->widget('zii.widgets.jui.CJuiDatePicker',array(
				'name'=>'dateEnd',
				// additional javascript options for the date picker plugin
				'options'=>array(
					'showAnim'=>'fold',
				),
				'htmlOptions'=>array(
					'style'=>'height:20px; width: 196px;',
				),
		)); ?>
	</div>
	<div class="controls" style="margin-top:50px;">
		<?php echo CHtml::submitButton('Submit',array("class"=>"btn btn-primary","style"=>"")); ?>
	</div>
	
	<?php $this->endWidget(); ?>
	
	<h4 style='font-size: 20px;margin-top: 20px;'>Statistics</h4>
	<table class="table table-condensed table-striped">
		<thead>
			<tr>
				<th>Help Topic</th>
				<th>Opened</th>
				<th>Closed</th>
				<th>Reopened</th>
				<th>Overdue</th>
			</tr>
		</thead>
	<tbody page="1" class="">
	<?php foreach ($ticketType as $key =>$type): ?>
		<tr>
			<th><?php echo $type->name;?></th>
			<td><?php $count = count (Ticket::model()->findAllByAttributes(array('ticket_type_id'=>$type->id))); echo $count; ?> </td>
			<td><?php 
				$criteria = new CDbCriteria;
			
				$criteria->together = true;
				$criteria->with=array('ticket');
				$criteria->compare('ticket.agency_id' , Yii::app()->user->model->agency_id , true);
				$criteria->compare('ticket.ticket_type_id' , $type->id , true);
				$criteria->compare('t.ticket_status_type_id' , 2 , true);
				//$criteria->addBetweenCondition('t.update_time', $date_begin, $date_end);
				//dump ($criteria);exit;
				$close = count(TicketStatusHistory::model()->findAll($criteria));
			
			
			echo $close;?></td>
			<td><?php 
			$criteria0 = new CDbCriteria;
			
			$criteria0->together = true;
			$criteria0->with=array('ticket');
			$criteria0->compare('t.ticket_status_type_id' , 1, true);
			$criteria0->compare('ticket.ticket_type_id' , $type->id , true);
			
			$reopentmp = count(TicketStatusHistory::model()->findAll($criteria0));
			
			
			$reopenforType = $reopentmp - $count;
			echo $reopenforType; ?></td>
			<td><?php echo $count + $reopenforType - $close; ?></td>
			
		</tr>
	<?php endforeach;?>
	<tr>
		<th>Total</th>
		<td><?php echo $countticket; ?></td>
		<td><?php echo $dataa[1];?></td>
		<td><?php echo $numberReopen; ?></td>
		<td><?php echo $countticket + $numberReopen - $dataa[1]; ?></td>
		
	</tr>
	
	</tbody>
	</table>
	<div class="total"><h3>Sum up:<h3> </div>
	<?php 
		$this->widget(
			'chartjs.widgets.ChPie', 
			array(
				'width' => 600,
				'height' => 300,
				'htmlOptions' => array(),
				'drawLabels' => true,
				'datasets' => $tmp,
				'options' => array()
			)
		); 
	?>
<div>